package com.itqf.exception;

import com.itqf.utils.R;
import org.apache.shiro.authc.UnknownAccountException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/10/19
 * @Time: 下午5:08
 */
@RestControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(UnknownAccountException.class)
    public R unknown(UnknownAccountException e){
        System.out.println("message:"+e.getMessage());
        System.out.println("LocalizedMessage:"+e.getLocalizedMessage());

        return R.error(e.getMessage());//code 1  msg
    }

    @ExceptionHandler(MyQuartzException.class)
    public R quartzException(MyQuartzException e){
        System.out.println("message:"+e.getMessage());

        return R.error(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public R exception(Exception e){
        System.out.println("message:"+e.getMessage());
        System.out.println("LocalizedMessage:"+e.getLocalizedMessage());

        return R.error(e.getMessage());
    }


}
